﻿using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 标高和轴网的创建.unit;

namespace 标高和轴网的创建
{
    [Transaction(TransactionMode.Manual)]
    public class Class1 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;
            UIDocument uIdocument = uiApp.ActiveUIDocument;
            Document document = uIdocument.Document;
            #region 创建组
            //IList<Reference> references = uIdocument.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element);
            //List<ElementId> ids = new List<ElementId>();
            //foreach (Reference reference in references)
            //{
            //    ids.Add(reference.ElementId);
            //}

            //using (Transaction transaction = new Transaction(document, "Group"))
            //{
            //    transaction.Start();
            //    document.Create.NewGroup(ids);
            //    transaction.Commit();
            //}


            #endregion

            //创建标高
            Transaction transaction = new Transaction(document, "标高");
            {
                transaction.Start();
                TransactionStatus transactionStatus = transaction.GetStatus();
                if(transactionStatus==TransactionStatus.Started)
                {
                    TaskDialog.Show("提示", "创建成功");
                }
                //高度转英尺 2000/304.8 或者 .Tofoot
                Level lecel1 = Level.Create(document, 20000.Tofoot());
                transaction.Commit();
            }
            return Result.Succeeded;
        }
    }
}
